#!/bin/bash

exec_times=80

# values=( 
#     100000 50000 25000 20000 18000 17000 16000
#     $(seq 15000 -1000 3000)
#     $(seq 3000 -500 1000)
#     $(seq 1000 -100 300)
#     $(seq 290 -10 250)
#     $(seq 249 -1 247)
# )

values=(
     $(seq 3000 -500 1000)
     $(seq 1000 -50 300)
     $(seq 300  -5 260)
     259
     257
     255
)

f="data_ex"
data_plot="data_plot"

make all >/dev/null

rm $f*

for e in $(seq $exec_times)
do
    fe=$f$e

    echo -n "" > $fe

    for i in ${values[@]}
    do
        echo -ne "$i\t"
        ./simu $i 2>/dev/null | tail -n 1 >> $fe &
    done

    sleep 1

    if (( $e % 5 == 0 ))
    then
        sleep 5
    fi

done

sleep 10

for e in $(seq $exec_times)
do
    fe=$f$e

    sort -n $fe > $fe"_tmp"
    mv $fe"_tmp" $fe

done

./stat $f $exec_times ${#values[@]} > $data_plot

./plot

eog utilizacao_atraso.png